﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.CompanyIndexViewModel>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Doanh nghiệp
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
	Doanh nghiệp
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%> 
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Toolbar" runat="server">
	<%= Html.Toolbar("Thêm mới", "/Company/Create/"  , "new") %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%if(ViewData["MessageInfo"]==null){ %>
	<form action="/Company" method="post" name="adminForm">
		<table width="100%">
			<tr>
			    <td align="left">
			        Tìm nhanh <%= Html.TextBox("Keyword", Model.Keyword) %>
			        <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
			    </td>
				<td align="right">
				<%=Html.DropDownList("ActivityYN", new SelectList(Model.ListActivityYN, "Key", "Value", Model.CurrentActivityYN).ToList(), "--Trạng thái kích hoạt --", new { onchange = "document.adminForm.submit();" })%>
			    </td>
			</tr>
		</table>
		<table width="100%" class="adminlist">
			<tr>
				<th width="10" align="right">
					STT
				</th>
				<th width="30"></th>
				<th width="30"></th>
				<th width="180">
					<%= Html.Sort("Tên doanh nghiệp","Name", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th width="180">
				    Địa chỉ
				</th>
				<th>
				    Điện thoại
				</th>
				<th width="100">Email</th>
				<th width="100">Website</th>				
				<th width="100">Kích hoạt?</th>
				<th width="90" align="center">Nổi bật?</th>				
				<th width="30">
					<%= Html.Sort("ID", "ID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
			</tr>
		<% 
			int i = 0;
    		foreach (var item in Model.Companies) {
				i++;
		%>		
			<tr>
				<td align="right">
					<%= i.ToString() %>
				</td>
				<td align="center">
					<%= Html.ActionImage("Sửa", "icon-24-edit.png", "Company", "Edit", new Dictionary<string, object>() { { "id", item.ID } })%>
				</td>
				 <td align="center">
					<%= Html.ActionImage("Xóa", "icon-24-delete.png", "Company", "Delete", new Dictionary<string, object>() { { "id", item.ID } })%>
				</td>
				<td>
					<%= Html.ActionLink(item.Name, "Details", new { id = item.ID })%>
				</td>
				<td>
				    <%= Html.Encode(item.Address) %>
				</td>
				<td>
				    <%=item.Phone %>
				</td>
				<td><%=item.Email%></td>
				<td><a href="<%= item.Website%>"><%= item.Website%></a></td>
				<td align="center">
                    <img alt="" id="imgPubYN_<%= item.ID %>" onclick="ChangePubYN(<%= item.ID %>);" value="<%= item.ActiveYN %>"
                        src="<%= item.ActiveYN ==true? "/Images/icon-32-apply.png" : "/Images/icon-32-cancel.png" %>" />
                </td>
                <td align=center>
                    <img alt="" id="hotYN_<%=item.ID %>" onclick="ChangeHotYN(<%=item.ID %>);" value="<%=item.HotYN %>"
                    src="<%=item.HotYN == true ? "/Images/icon-32-apply.png" : "/Images/icon-32-cancel.png" %>" />
                </td>
				<td>
					<%= Html.Encode(item.ID) %>
				</td>
			</tr>
	    
		<% } %>

		</table>
		<table width="100%">
            <tr>
                <td align="center">
             
                <div class="pager">
                <label>Hiển thị #</label>
                    <%
                        int[] pageSizeList = {1, 5, 10, 15, 20, 25, 50, 100};
                    %>
                    <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.Companies.PageSize), new { onchange = "document.adminForm.submit();" })%>

                    <%= Html.Pager(Model.Companies.PageSize, Model.Companies.PageNumber, Model.Companies.TotalItemCount)%>
                </div>
                </td>
            </tr>
        </table>
		<%= Html.Hidden("order")%>
		<%= Html.Hidden("orderDir")%>
	</form>
<% } %>
<script type ="text/javascript">
    function ChangePubYN(id) {
			var obj = $("#imgPubYN_" + id);
			ApplyChangeYN("/AjaxData/UpdateCompanyActiveYN/" + id + '/' + obj.attr("value"), id, obj);    }
    function ChangeHotYN(id) {
        var obj = $("#hotYN_"+ id);
        ApplyChangeYN("/AjaxData/UpdateCompanyHotYN/" + id + '/' + obj.attr("value"), id, obj);
    }
</script>
</asp:Content>
